﻿using System.ServiceModel;
using System.ServiceModel.Activation;
using HSS.ServiceModel;

namespace TestVirtualService
{
	[ServiceBehavior(Namespace = "https://secure.highspeed-solutions.net/testing", InstanceContextMode = InstanceContextMode.PerCall)]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	//[BypassAuthentication]
	//[Authorization("Custom")]
	public class TestService : ITestService
	{
		int stateCounter = 0;

		public TestService()
		{
			stateCounter++;
		}

		[BypassAuthentication]
		public void DoSomeWork()
		{
			//System.Threading.Thread.Sleep(1000 * 65); // time out for sixty seconds...
			System.Diagnostics.Debug.WriteLine("DoSomeWork {0} Instance: {1}", "TestService", stateCounter);
		}

		//[BypassAuthentication]
		public string MoreWork(string userName)
		{
			System.Diagnostics.Debug.WriteLine("MoreWork {0} Instance: {1}", "TestService", stateCounter);
			//System.Threading.Thread.Sleep(500);
			//throw new Exception("Test exception!!");
			return string.Format("Hello {0}!", userName);
		}

		public void Dispose()
		{
			System.Diagnostics.Debug.WriteLine("{0} Disposing: {1}", "TestService", stateCounter);
		}
	}
}